<template>
  <div id="selectionlist" class="task">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/selection' }">干部选任</el-breadcrumb-item>
      <el-breadcrumb-item>待办理事项</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxd" style="margin-top:10px">
      <!--列表-->
      <el-radio-group v-model="taskflag" @change="radioChange" style="margin:15px">
        <el-radio-button label="待办理事项列表">
        </el-radio-button>
        <el-radio-button label="已办理事项列表">
        </el-radio-button>
      </el-radio-group>
      <el-table :data="tasklist" highlight-current-row v-loading="listLoading" style="width: 100%;border-top: 1px solid #95B8E7;" :height="tableHeight" border id="tasklist">
        <el-table-column label="环节" align="right" width="300px">
          <template slot-scope="scope">
            <span v-if="scope.row.step==='动议'">动议后续环节选择</span>
            <span v-else>{{scope.row.step}}</span>
          </template>
        </el-table-column>
        <el-table-column label="待办" align="left">
          <template slot-scope="scope">
            <span v-if="scope.row.num===0">{{scope.row.num}}人</span>
            <el-button v-else-if="scope.row.num" @click="detail(scope.row.step)" type="primary">{{scope.row.num}}人</el-button>
            <i v-else class="icon_c_-1"> </i>
          </template>
        </el-table-column>
      </el-table>
    </section>
  </div>
</template>

<script>
export default {
  data () {
    return {
      taskflag: '待办理事项列表',
      tasklist: [
        {
          step: '查核干部档案',
          num: 0
        },
        {
          step: '查核有关事项',
          num: 0
        },
        {
          step: '征求纪检监察部门意见',
          num: 0
        },
        {
          step: '线索举报调查',
          num: 0
        },
        {
          step: '公示',
          num: 0
        }
      ],
      listLoading: false,
      tableHeight: 100
    }
  },
  methods: {
    radioChange () {
      if (this.taskflag === '已办理事项列表') {
        this.$router.push({path: '/selection/sendofflist'})
      }
    },
    detail (step) {
      switch (step) {
        case '公示':
          this.$router.push({path: '/selection/gongshicn'})
          break
        case '查核干部档案':
          this.$router.push({path: '/selection/necessary/todo/1'})
          break
        case '查核有关事项':
          this.$router.push({path: '/selection/necessary/todo/2'})
          break
        case '征求纪检监察部门意见':
          this.$router.push({path: '/selection/necessary/todo/3'})
          break
        case '线索举报调查':
          this.$router.push({path: '/selection/necessary/todo/4'})
          break
      }
    },
    handleSizeChange (val) {
      this.changeSizeFlag = true
      this.pageNum = 1
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      if (this.changeSizeFlag === false) {
        this.pageNum = val
        this.getList()
      }
    },
    getList () {
      this.listLoading = true
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/selection/home/getStatNum`)
        .then(response => {
          if (response.data.success) {
            this.listLoading = false
            this.tasklist[0].num = response.data.result.num1
            this.tasklist[1].num = response.data.result.num2
            this.tasklist[2].num = response.data.result.num3
            this.tasklist[3].num = response.data.result.num4
            this.tasklist[4].num = response.data.result.num5
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '获取失败:' + error,
            type: 'error'
          })
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 190
      })
    }
  },
  mounted () {
    this.getList()
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
  #selectionlist #tasklist .is-right {
    text-align: right !important;
  }
  #selectionlist #tasklist .is-left {
    text-align: left !important;
  }
  #selectionlist #tasklist .cell i{
    width: 30px;
    height: 30px;
    background-position: center center;
    background-repeat: no-repeat;
    float: center;
    display: block;
    cursor: pointer;
    margin:0;
  }
  #selectionlist #tasklist .cell{
    font-size:var(--size20) !important;
    font-family:'Microsoft YaHei';
  }
  .task .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    text-align: center;
    border-right: #95B8E7 solid 1px;
    border-bottom: #95B8E7 solid 1px;
    min-height: 30px;
    line-height:30px;
  }
  .task .wboxd .el-table td, .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体';
    text-align:center
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    height:33px;
  }
  #selectionlist .wboxs{
    height:45px;
    padding-top:10px;
  }
  #selectionlist .el-table__row{
    height: 50px;
  }
  #selectionlist #legent{
    float:right;
    margin-right: 20px;
  }
  #selectionlist #legent div{
    float:left;
    line-height: 42px;
    font-size:var(--size14);
  }
  #selectionlist #legent i{
    width: 30px;
    height: 30px;
    background-position: center center;
    background-repeat: no-repeat;
    float: left;
    display: block;
    margin:5px 5px 0 10px;
  }
  #selectionlist .cell i{
    background-position: center center;
    background-repeat: no-repeat;
    float: center;
    display: block;
    cursor: pointer;
    margin:0 auto;
  }
</style>
<style scoped>
  h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
